package org.example.service;

import org.example.dao.TestDAO;
import org.example.dao.TestDAOImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

/**
 * @author zxiaoming
 * @Description:
 * @date 2021/2/2323:36
 */
@Service//代表把TestServiceImpl的实例交给spring容器进行管理
public class TestServiceImpl implements TestService {
    @Autowired//把Spring容器中TestDAO的实例注入到testDAO属性中
    TestDAO testDAO;

    /**
     * 完成对象运行期间的TestDAO类型实例的注入
     * @param testDAO
     */
    public void setTestDAO(TestDAO testDAO) {
        this.testDAO = testDAO;
    }

    @Override
    public void callDAOMethod() {
        testDAO.hello();
    }
}
